package com.poc.importacao.baseabstract;
import java.io.IOException;
import java.sql.SQLException;

import com.poc.database.DatabaseManager;

public abstract class AbstractManager {

	/* INSERT INTO RELACIONAMENTO_GEO (codlugar1, codlugar2, codtiporelgeo, datacriacao) VALUES
	 * - Afluente, rio principal, afluente de, data
	 * - Bacia intera, bacia principal, esta contida em, data
	 * - Rio, bacia, faz parte de, data
	 * - Rio, estado, intercepta, data
	 * - Rio, Municipio, intercepta, data
	 * - Rio, Microrregiao, intercepta, data
	 * - Rio, Mesorregiao, intercepta, data
	 * - Rio, Macrorregiao, intercepta, data
	 * 
	 * - Bacia, Municipio, intercepta, data
	 * - Bacia, estado, intercepta, data
	 * - Bacia, Microrregiao, intercepta, data
	 * - Bacia, Mesorregiao, intercepta, data
	 * - Bacia, Microrregiao, intercepta, data
	 * 
	 */
	public static final String INSERT_RELACIONAMENTO_PARAMS = "(%s,%s,%s,CURRENT_DATE),\n";

	public static final Integer COD_TIPO_LUGAR_RIO = 10;

	public static final Integer COD_TIPO_LUGAR_BACIA = 11;

	public static final double BACIA_COUNT = 667.0;

	public static final double RIOS_COUNT = 5384.0;

	public static final Double ESTADO_COUNT = 27.0;
	
	public static DatabaseManager databaseManager;

	protected static DatabaseManager getDatabaseManager() throws SQLException {
		if(AbstractManager.databaseManager == null) {
			AbstractManager.databaseManager = new DatabaseManager("jdbc:postgresql://127.0.0.1:5432/gazetteer_final","postgres", "123");			
		}
		return AbstractManager.databaseManager;
	}

	public abstract void createInserts(String fileName) throws SQLException, IOException;

	protected void finalize() {
		try {
			AbstractManager.databaseManager.finalize();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}